<!DOCTYPE html>
<html ng-app="app">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>buy-book-list</title>
</head>
<body >
<div ng-controller="AppCtrl">
    <div ng-repeat="book in list">
        <input type="checkbox" ng-model="book.yes" ng-click="check()">
        <span>{{book.name}}</span>
        <span>{{insert(book.price)}}</span>
    </div>
    <span>your name</span><input ng-model="who">
    <br/>
    <span>your id</span><input ng-model="id">
    <br/>
    <button ng-click="post()">post</button>
    <br/>
    <span>{{msg}}</span>
    <br/>
    <span>每个同学只能post一次</span>
    <br/>
    <div ng-if = 'tol'>
        <span>please pay {{insert(tol)}} 转账（备注姓名)</span>
        <br/>
        <span>binary_sea#yahoo.co.jp(#改@)，曾健骏，我核对金额后手动改变isPaid状态，所以会有延迟，</span>
        <br/>
    </div>
    <button ng-click="getAllInfo()">fetch all transactions</button>
    <div ng-repeat="tran in allInfo">
        <span>{{tran.who}} bookTaken?{{tran.taken}} ,isPaid:</span>
        <span ng-style="(!tran.payed?{'color':'red'}:{'color':'black'})">{{tran.payed}}</span>
        <span>，need to pay {{insert(tran.tol)}}, buys {{tran.list.toString()}} </span>
    </div>
    <br/>


    <table border="1">
        <tr >
            <td>Name</td>
            <!--bookName-->
            <td ng-repeat="book in list">
                {{book.name}}
            </td>
            <!--end bookName-->
        </tr>
        <tr >
            <td>Price</td>
            <!--book price-->
            <td ng-repeat="book in list">
                {{insert(book.price)}}
            </td>
            <!--end book price-->
        </tr>
        <!--tran info-->
        <tr ng-repeat="tran in allInfo">
            <td>{{tran.who}}</td>
            <td ng-repeat="n in tran.nlist track by $index">
                {{n}}
            </td>
        </tr>
        <!--end tran info-->
    </table>




    <button ng-click="getBookSum()">fetch book summary</button>
    <div ng-repeat="(key,val) in sumBook">
        {{(key==='tol'?insert(val):val)+':'+key }}
        <!--<span>{{book}}</span>-->
        <!--<span>{{sumBook[book]}}</span>-->
    </div>
</div>
</body>
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script src="./ctrl.js"></script>
<script src="./urlCnst.js"></script>
</html>
